import { AxiosInstance } from './types'
import Axios from './core/Axios'
import { extend } from './helpers/util'

// 定义工厂方法
function createInstance(): AxiosInstance {
  const content = new Axios()
  // instance中的this 要和后面的方法保持一致 实现混合后 既能直接执行Axios() 又能Axios.post()
  const instance = Axios.prototype.request.bind(content)
  // 实现混合类
  extend(instance, content)
  return instance as AxiosInstance
}
const axios = createInstance()
export default axios
